package com.example.administrator.testproject;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import java.util.ArrayList;
import java.util.List;

public class HomeActivity extends AppCompatActivity implements View.OnClickListener {

    private AutoScrollViewPager viewPager;
    private EducationHistoeySchoolAdapter educationHistoeySchoolAdapter;
    private Button btn;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_home);
        btn = (Button)findViewById(R.id.btn);
        btn.setOnClickListener(this);
        viewPager = (AutoScrollViewPager)findViewById(R.id.viewpager);
        educationHistoeySchoolAdapter = new EducationHistoeySchoolAdapter(this);
//        viewPager.setAdapter(educationHistoeySchoolAdapter);
        List<String> list=new ArrayList<>();
        list.add("北师大天津附属中学");
        list.add("平山小学1");
        list.add("平山道小学2");
        list.add("平山道小学3");
        list.add("平山道小学4");
        List<Integer> imageIdList = new ArrayList<Integer>();
        imageIdList.add(R.mipmap.bg_banner);
        imageIdList.add(R.mipmap.bg_banner);
        imageIdList.add(R.mipmap.bg_banner);
        imageIdList.add(R.mipmap.bg_banner);
        imageIdList.add(R.mipmap.bg_banner);
        educationHistoeySchoolAdapter.setData(list);
        viewPager.setAdapter(new ImagePagerAdapter(this, imageIdList).setInfiniteLoop(true));
        viewPager.setInterval(2000);
        viewPager.startAutoScroll();
        viewPager.setCurrentItem(Integer.MAX_VALUE / 2 - Integer.MAX_VALUE / 2 % list.size());
    }

    @Override
    protected void onPause() {
        super.onPause();
        viewPager.stopAutoScroll();
        System.gc();
    }

    @Override
    public void onClick(View view) {
        startActivity(new Intent(this,SecondActivity.class));
    }
}
